<%= javascript_include_tag 'pagination' %>

<div class="portlet">
  <div class="portlet-header">
    <h1><%=t ".title"%></h1>
  </div>

  <div class="portlet-content">

    <% form_tag contact_profiles_update_path do |f| %>
      <h3><%= t('activerecord.models.country') %></h3>
      <table style="border: none">
        <% actual_column = 0 %>
        <% for country in @countries %>
          <% actual_column += 1 %>
          <% if actual_column == 1 %>
            <% tr_open = 1 %>
            <tr>
          <% end %>
          <td>
            <%= check_box_tag("profile[countries][]", country.id, @profiles_country.include?(country.id)) %>
            <%=h country.name %>
          </td>
          <% if actual_column == @country_count_columns_by_row %>
            </tr>
            <% actual_column = 0 %>
            <% tr_open = 0 %>
          <% end %>
        <% end %>
        <% if tr_open == 1 %>
            </tr>
        <% end %>
      </table>

      <h3><%= t('activerecord.models.thematic') %></h3>
      <table style="border: none">
        <% actual_column = 0 %>
        <% for thematic in @thematics %>
          <% actual_column += 1 %>
          <% if actual_column == 1 %>
            <% tr_open = 1 %>
            <tr>
          <% end %>
          <td>
            <%= check_box_tag("profile[thematics][]", thematic.id, @profiles_thematic.include?(thematic.id)) %>
            <%=h thematic.name_to_local_language %>
          </td>
          <% if actual_column == @thematic_count_columns_by_row %>
            </tr>
            <% actual_column = 0 %>
            <% tr_open = 0 %>
          <% end %>
        <% end %>
        <% if tr_open == 1 %>
            </tr>
        <% end %>
      </table>

      <h3><%= t('activerecord.models.descriptor') %></h3>

      <table style="border:0px">
          <tr>
            <!--th><%#= label_tag t('lbl_tag_search') %></th-->
            <th>
              <%= text_field_tag 'tag' %>              
              <%= link_to_remote(t('btn_contact_profile_add_tag'),  :update => 'tag_list', :url => {:action => :add_tag}, :with => "'tag='+$('tag').value") %>
              <%= image_tag("load.gif", :align => "absmiddle", :border => 0, :id => "spinner", :style =>"display: none;" ) %>
            </th>
          </tr>
      </table>

      <div class="auto_complete" id="tag_auto_complete" ></div>

      <div id="tag_list">
        <%= render :partial => 'contact_profiles_tag_list' %>
      </div>

      <%= auto_complete_field 'tag',
        :url=>{:action=>'auto_complete_tag'},
        :frequency => 0.5,
        :min_chars => 3,
        :indicator => 'spinner'
      %>


      <div class="line-buttons">
        <%= submit_tag t('btn_contact_profile_update'), :name => :update_profile %>
      </div>

    <% end %>

  </div>

  <div class="portlet-footer">
  </div>
</div>